package common;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;


public class UserInfo implements Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7237464322284879156L;
	private String user_name;
	private String display_name;
	private String address;
	private int age;
	private String  avatarUrl;
	
	public UserInfo(String User, String DislayName, String Address, int Age, String Avatar)
	{
		user_name = User;
		display_name = DislayName;
		address = Address;
		age = Age;
		avatarUrl = Avatar;
	}
	
	
	public byte[] Serialize() throws IOException
	{
		ByteArrayOutputStream byte_out = new ByteArrayOutputStream();
		ObjectOutputStream out = new ObjectOutputStream(byte_out);
		out.writeObject(this);
		return byte_out.toByteArray();
	}
	
	
	public static UserInfo readObject(byte[] data) throws ClassNotFoundException, IOException
	{
		Object o  =  new ObjectInputStream(new ByteArrayInputStream(data)).readObject();
		return (UserInfo)o;
	}
	
	public String getUserName() {
		return user_name;
	}
	
	public String getDisplayName() {
		return display_name;
	}
	
	public String getAddress() {
		return address;
	}
	
	public int getAge() {
		return age;
	}
	
	public String ImageData() {
		return avatarUrl;
	}

}
